package cn.hrlly.tao2shou.utils;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * User: gengliang
 * Date: 2016-01-25
 * Time: 12:06
 */

public class DatabaseHelper extends SQLiteOpenHelper {

    final String CREATE_TABLE_USER="create table user_info ("+
            "id integer primary key,"+
            "user_id varchar(50),"+
            "nickname varchar(50),"+
            "gender varchar(4),"+
            "university varchar(50),"+
            "head_portrait varchar(100),"+
            "phone_number varchar(12))";

    final String CREATE_TABLE_HISTORY="create table history ("+
            "id integer primary key,"+
            "release_id varchar(50),"+
            "commodity_name varchar(50),"+
            "commodity_photo varchar(50),"+
            "commodity_price float)";

    final String CREATE_TABLE_HISTORY_SEARCH="create table history_search("+
            "id integer primary key autoincrement,"+
            "search_name varchar(50))";

    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
        super(context, name, factory, version, errorHandler);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE_USER);
        db.execSQL(CREATE_TABLE_HISTORY);
        db.execSQL(CREATE_TABLE_HISTORY_SEARCH);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
